<?php
    session_start();
    include("includes/checklogged.php");
    include("includes/mysql_connect.inc.php");
    check_logged();
?>

<?php include('includes/header.php'); ?>
<?php 
  if ($_SESSION["logged"] == "admin"){
    include('includes/nav.php'); 
  }
  else{ 
	include('includes/nav2.php');
}?> 

<div id="content">
</br>
<u>CREATE USER</u>
<?php
include ("includes/userfunctions.php");
//==================================================================================
if (!isset ($_POST["username"]))
{
   UserForm(ADDUSERSUBMITTEXT, ADDFUNCTION);
}
else
{
   if (validateUserForm(ADDUSERSUBMITTEXT))
   {
      addUserToDB();
      $errmsg = userSaved;
      UserForm(ADDUSERSUBMITTEXT, ADDFUNCTION);
   }
   else
   {
      UserForm(ADDUSERSUBMITTEXT, ADDFUNCTION);
   }
}   
//====================================================================================
?>
<FORM align=center>
<INPUT TYPE="BUTTON" VALUE="Reset" ONCLICK="window.location.href='createuser.php'">  
</FORM>
</FORM>
</div> <!-- end #content -->

<?php 
  if ($_SESSION["logged"] == "admin"){
    include('includes/sidebar.php'); 
  }
  else{ 
	include('includes/sidebar3.php');
  }?> 
<?php include('includes/footer.php'); ?>
<?php mysql_close($link); ?>